/*!
\copyright  Copyright (c) 2025 Qualcomm Technologies International, Ltd.
            All Rights Reserved.
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\file
\ingroup    user_eq
\brief      Load all the data from NVM

*/

#include "user_eq_data.h"
#include "user_eq_ctx.h"
#include "user_eq_audio_config.h"
#include "user_eq_user_settings.h"

#include <panic.h>

void UserEq_DataLoad(void)
{
    UserEq_AudioConfigLoadEqParams(&UserEq_CtxGet()->eq);

    UserEq_SettingsPopulateFromPsStorage(&UserEq_CtxGet()->eq);

    user_eq_bank_t *user = &UserEq_CtxGet()->eq.user;

    UserEq_CtxGet()->gains = PanicUnlessMalloc(user->number_of_bands * sizeof(int16));

    for(uint8 i = 0; i < user->number_of_bands; ++i)
    {
        UserEq_CtxGet()->gains[i] = user->params[i].gain;
    }
}
